inspector: Avoid size changes of button path
authorMatthias Clasen <mclasen@redhat.com>
Sat, 10 May 2014 03:57:38 +0000 (23:57 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 11 May 2014 02:04:32 +0000 (22:04 -0400)
modules/inspector/button-path.c
modules/inspector/button-path.h
modules/inspector/button-path.ui
modules/inspector/window.c

index 339d4a16adc3c6669bd5f46c65b719728911583e..6019143c522c90a8c129bde0bc294a9b42933566 100644 (file)
@@ -54,28 +54,33 @@ gtk_inspector_button_path_new (void)
 }
 
 void
-gtk_inspector_button_path_set_widget (GtkInspectorButtonPath *bp,
-                                      GtkWidget          *widget)
+gtk_inspector_button_path_set_object (GtkInspectorButtonPath *bp,
+                                      GObject                *object)
 {
-  gchar *path, **words;
-  gint i;
-  GtkWidget *b;
   GtkContainer *box = GTK_CONTAINER (bp->priv->button_box);
+  GtkWidget *b;
 
   gtk_container_foreach (box, (GtkCallback)gtk_widget_destroy, NULL);
 
-  path = gtk_widget_path_to_string (gtk_widget_get_path (widget));
-  words = g_strsplit (path, " ", 0);
-
-  for (i = 0; i < g_strv_length (words); i++)
+  if (GTK_IS_WIDGET (object))
     {
-      b = gtk_button_new_with_label (words[i]);
-      gtk_widget_show (b);
-      gtk_container_add (box, b);
-    }
+      GtkWidget *widget = GTK_WIDGET (object);
+      gchar *path, **words;
+      gint i;
 
-  g_strfreev (words);
-  g_free (path);
+      path = gtk_widget_path_to_string (gtk_widget_get_path (widget));
+      words = g_strsplit (path, " ", 0);
+
+      for (i = 0; i < g_strv_length (words); i++)
+        {
+          b = gtk_button_new_with_label (words[i]);
+          gtk_widget_show (b);
+          gtk_container_add (box, b);
+        }
+
+      g_strfreev (words);
+      g_free (path);
+    }
 }
 
 // vim: set et sw=2 ts=2:
index 32f3d934424dddecc8abe3f23fbe6e5a5607a75c..6ee59b33257f4ab3e799dccafe0cc3b717604702 100644 (file)
@@ -51,8 +51,8 @@ G_BEGIN_DECLS
 
 GType      gtk_inspector_button_path_get_type   (void);
 GtkWidget *gtk_inspector_button_path_new        (void);
-void       gtk_inspector_button_path_set_widget (GtkInspectorButtonPath *bp,
-                                                 GtkWidget              *widget);
+void       gtk_inspector_button_path_set_object (GtkInspectorButtonPath *bp,
+                                                 GObject                *object);
 
 G_END_DECLS
 
index b586f4198c3e7ab55dba4103510feb47d454193f..5f832f7170d2f677c309979df3fb19447880a53c 100644 (file)
@@ -9,22 +9,34 @@
         <property name="vscrollbar-policy">never</property>
         <property name="hexpand">True</property>
         <child>
-          <object class="GtkButtonBox" id="button_box">
-            <property name="visible">True</property>
+          <object class="GtkBox">
             <property name="orientation">horizontal</property>
-            <property name="hexpand">True</property>
-            <property name="margin">6</property>
-            <property name="spacing">0</property>
-            <property name="layout-style">start</property>
-            <style>
-              <class name="linked"/>
-            </style>
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkButton" id="placeholder">
+                <property name="margin">6</property>
+                <property name="label">X</property>
+              </object>
+            </child>
             <child>
-              <object class="GtkLabel">
+              <object class="GtkButtonBox" id="button_box">
+                <property name="orientation">horizontal</property>
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Choose a widget through the inspector</property>
                 <property name="hexpand">True</property>
-                <property name="xalign">0.5</property>
+                <property name="margin">6</property>
+                <property name="spacing">0</property>
+                <property name="layout-style">start</property>
+                <style>
+                  <class name="linked"/>
+                </style>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Choose a widget through the inspector</property>
+                    <property name="hexpand">True</property>
+                    <property name="xalign">0.5</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
       </object>
     </child>
   </template>
+  <object class="GtkSizeGroup">
+    <property name="mode">vertical</property>
+    <property name="ignore-hidden">False</property>
+    <widgets>
+      <widget name="placeholder"/>
+      <widget name="button_box"/>
+    </widgets>
+  </object>
 </interface>
index 04790b26cc854597afeb860bed581ee4b430403c..499129f790746159d070a289bf8aea1a9613c246 100644 (file)
@@ -75,20 +75,22 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
       gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
       gtk_inspector_signals_list_set_object (GTK_INSPECTOR_SIGNALS_LIST (iw->signals_list), selected);
       gtk_inspector_object_hierarchy_set_object (GTK_INSPECTOR_OBJECT_HIERARCHY (iw->object_hierarchy), selected);
+      gtk_inspector_button_path_set_object (GTK_INSPECTOR_BUTTON_PATH (iw->button_path), selected);
 
       if (GTK_IS_WIDGET (selected))
         {
           GtkWidget *widget = GTK_WIDGET (selected);
 
           gtk_inspector_flash_widget (iw, widget);
-          gtk_inspector_button_path_set_widget (GTK_INSPECTOR_BUTTON_PATH (iw->button_path), widget);
           gtk_inspector_classes_list_set_widget (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), widget);
           gtk_inspector_css_editor_set_widget (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), widget);
+          gtk_widget_set_visible (iw->classes_list, TRUE);
+          gtk_widget_set_visible (iw->widget_css_editor, TRUE);
         }
       else
         {
-          gtk_widget_set_sensitive (iw->classes_list, FALSE);
-          gtk_widget_set_sensitive (iw->widget_css_editor, FALSE);
+          gtk_widget_set_visible (iw->classes_list, FALSE);
+          gtk_widget_set_visible (iw->widget_css_editor, FALSE);
         }
     }
 }